home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / exploits / wuftpd-sploit / port.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-13  |  1.2 KB  |  43 lines

  1. #include <stdio.h>
  2. #include <sys/types.h>
  3.  
  4. /* Get rid of implicit declarations */
  5. unsigned short int htons();
  6. unsigned short int ntohs();
  7.  
  8. #define UC(b) (((int) b) & 0xff)
  9.  
  10. void getport(u_long *p1, u_long *p2, unsigned short int port)
  11. {
  12.   u_char *p;
  13.   unsigned short int it;
  14.  
  15.   /* We get "PORT ...,16,120" as the 5th and 6th args of port,    */
  16.   /* which tells us where we are getting our data, on the client  */
  17.   /* transfer port.                                               */
  18.  
  19.   /* p1 is MSB of port, p2 is LSB of port                         */
  20.   /* given to us by PORT                                          */
  21.   
  22.   it = port;
  23.   
  24.   p  = (u_char *) & it;
  25.   *p1 = UC(p[1]), *p2 = UC(p[0]);
  26. }
  27.  
  28. unsigned short int getport1(u_long p1, u_long p2)
  29. {
  30.   unsigned short int it;
  31.  
  32.   /* We get "PORT ...,16,120" as the 5th and 6th args of port,    */
  33.   /* which tells us where we are getting our data, on the client  */
  34.   /* transfer port.                                               */
  35.  
  36.   /* p1 is MSB of port, p2 is LSB of port                         */
  37.   /* given to us by PORT                                          */
  38.   
  39.   it = htons((p1 << 8) | p2);
  40.  
  41.   return ntohs(it);  
  42. }
  43.